<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" v-model="jsq1">
    <input type="text" v-model="jsq2">
    <input type="button" value="加" @click="f(1)">
    <input type="button" value="减" @click="f(2)">
    <input type="button" value="乘" @click="f(3)">
    <input type="button" value="除" @click="f(4)">
    <div>结果:<b>{{info}}</b></div>
</div>
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js"></script>
<script>
    //创建Vue对象
    let v = new Vue({
        el: "div",/*设置被Vue管理的元素选择器 el:element元素*/
        data: {
            jsq1: "",
            jsq2: "",
            info: ""
        },
        methods: {
            f: function (x) {
                if (isNaN(v.jsq1) || isNaN(v.jsq2)) {
                    v.info = "输入错误"
                    return;
                }else {
                switch (x) {
                    case 1:
                        v.info = v.jsq1 * 1 + v.jsq2 * 1
                        break;
                    case 2:
                        v.info = v.jsq1 * 1 - v.jsq2 * 1
                        break;
                    case 3:
                        v.info = v.jsq1 * 1 * v.jsq2 * 1
                        break;
                    case 4:
                        v.info = v.jsq1 * 1 / v.jsq2 * 1
                        break;
                }
                }
            },
        }
    })
</script>
</body>
</html>